<%-- 
    Document   : sendMail
    Created on : 6-jan-2013, 21:32:49
    Author     : Serife
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <link href="../style/general.css" type="text/css" rel="Stylesheet">
        <link href="/style/student.css" type="text/css" rel="Stylesheet"> 
        <link href="../style/admin.css" type="text/css" rel="Stylesheet">

        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js" type="text/javascript"></script>

        <!-- include jQuery UI  From Google Code-->
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js"></script>


        <script type="text/javascript">
            $(document).ready(function(){
                $("#menu a").hover(function() {
                    $(this).stop().animate({ backgroundColor: "#4e88b2"}, 800);
                },function() {
                    $(this).stop().animate({ backgroundColor: "#504e4e" }, 800);
                });
				
            }); 
        </script> 

        <jsp:useBean id="inhoud" scope="application" class="models.Bean" />   
        <jsp:setProperty name="inhoud" property="language" value="<%= models.Bean.getLanguage() %>" />
        
        <title>
            Three 2 Learn | Email
        </title>
        
    </head>
    <body>
                   
        
                <%@ page import="java.util.*" %>
                <%@ page import="javax.mail.*" %>
                <%@ page import="javax.mail.internet.*" %>
                <%@ page import="javax.activation.*" %>
     
                
                <%
                 String _emailTo= request.getParameter("emailTo");
                 String _subject= request.getParameter("subject"); 
                 String _emailFrom = request.getParameter("emailFrom");
                 String _content = request.getParameter("content"); 
                  Properties props = new Properties();
                  props.put("mail.smtp.socketFactory.port", "465");
                  props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");
                  props.put("mail.smtp.host", "smtp.gmail.com");
                  props.put("mail.smtp.port", "465");
                  //props.put("mail.smtp.port", "587");
                  props.put("mail.smtp.auth", "true");
                  props.put("mail.smtp.starttls.enable", "true");
                  // String from = "32learn2012@gmail.com";
                  Session mailSession = Session.getDefaultInstance(props, new javax.mail.Authenticator() 
                  {
                        String from = "32learn2012@gmail.com";
                        protected PasswordAuthentication getPasswordAuthentication() {
                        return new PasswordAuthentication(from, "Wachtwoord8");
                        }
                  });
 
                                try {
                                MimeMessage message = new MimeMessage(mailSession);
                                message.setFrom(new InternetAddress(_emailFrom));//Sender Id
                                message.addRecipient(Message.RecipientType.TO, new InternetAddress(_emailTo));
                                message.setSubject(_subject);
                                message.setText("Email from: " +_emailFrom +"\n" + 
                                        "Subject: "+ _subject + "\n \n" +_content); 
                                
                                // send message.
                                Transport.send(message);
                                System.out.println("message sent successfully");
                                
                                } catch (MessagingException e) {
                                throw new RuntimeException(e);
                                } 
                %>
    
        <div id="header">
            <div id="topmenu">
                <div id="topmenu">
                    <ul class="login">
                        <li><img src="style/logo32L.png"/></li>
                        <li><a href="/language?lang=nl" title="Nederlands"><img src="images/flags/nl.png"></a></li>
                        <li><a href="/language?lang=en" title="English"><img src="images/flags/uk.png"></a></li>
                        <c:choose>
                            <c:when test="${loggedin eq 'true'}">
                                <li><a href="/logout" id="toggleLogout" >
                                        <jsp:setProperty name="inhoud" property="key" value="LogOut" />
                                        <jsp:getProperty name="inhoud" property="key" />
                                    </a></li>
                            </c:when>
                            <c:otherwise>
                                <li><a href="#" id="toggleLogin" >
                                        <jsp:setProperty name="inhoud" property="key" value="Login" />
                                        <jsp:getProperty name="inhoud" property="key" />
                                    </a></li>
                            </c:otherwise>
                        </c:choose>
                        
                    </ul>
                </div>
                
            </div>

            <div class="middle">
                <div id="menu">
                    <ul>
                        <li><a href="index.jsp">
                                <jsp:setProperty name="inhoud" property="key" value="Homepage" />
                                <jsp:getProperty name="inhoud" property="key" />
                            </a></li>
                        <li><a href="/courses">
                                <jsp:setProperty name="inhoud" property="key" value="Courses" />
                                <jsp:getProperty name="inhoud" property="key" />
                            </a></li>
                        <li><a href="three2Learn.jsp">Three2Learn</a></li>
                        <li><a href="information.jsp">
                                <jsp:setProperty name="inhoud" property="key" value="Information" />
                                <jsp:getProperty name="inhoud" property="key" />
                            </a></li>
                        <li><a href="fag.jsp">
                                <jsp:setProperty name="inhoud" property="key" value="FAQ" />
                                <jsp:getProperty name="inhoud" property="key" />
                            </a></li>
                        <li><a href="contact.jsp" class="lastItem">Contact</a></li>
                    </ul>
                </div>
            </div>
        </div>
        <div id="subcontainer">
            <div class="right">
                <h2 align="center">
                    <br><br>
                     <jsp:setProperty name="inhoud" property="key" value="Done" />
                     <jsp:getProperty name="inhoud" property="key" />
                </h2>
                
            </div>
        </div>
    </body>
</html>
